package com.qipay.order.config;

import java.util.Map;
import java.util.TreeMap;

/**
 * Creator: Yao
 * Date:    2017/9/24
 * For:
 * Other:
 */
public enum OrderChannelEnum {

    WECHAT(1, "微信扫码"),
    WECHAT_WAP(6, "微信WAP"),
    WECHAT_OFFICE_ACCOUNT(4, "微信公众号"),

    QQ(5, "QQ扫码"),
    QQ_WAP(7, "QQ WAP"),

    ALIPAY(2, "支付宝扫码"),
    ALIPAY_WAP((byte)9, "支付宝WAP"),
    ALIPAY_SERVICE((byte)8, "支付宝服务号"),

    JD((byte)10, "京东扫码"),

    NET(3, "银联网关"),
    UNION_NET(11, "银联扫码"),
    UNION_QUICK(12, "银联快捷"),

    WITHDRAW(99, "代付");

    private int type;
    private String info;

    OrderChannelEnum(int type, String info) {
        this.type = type;
        this.info = info;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String getInfo() {
        return info;
    }

    public void setInfo(String info) {
        this.info = info;
    }

    public static String getInfo(int type) {

        String info = "";

        for (OrderChannelEnum p : OrderChannelEnum.values()) {
            if (p.getType() == type) {
                info = p.getInfo();
                break;
            }
        }

        return info;
    }

    public static OrderChannelEnum getByType(int type) {
        for (OrderChannelEnum p : OrderChannelEnum.values()) {
            if (p.getType() == type) {
                return p;
            }
        }
        return null;
    }


    public static Map<Integer, String> map() {

        // init
        Map<Integer, String> map = new TreeMap<>();

        // fill
        for (OrderChannelEnum p : OrderChannelEnum.values()) {
            map.put(p.getType(), p.getInfo());
        }
        map.put(0, "所有");

        return map;
    }
}
